<!DOCTYPE html>
<html lang="en" style="background: #F1F1F1 !important;overflow-y: scroll">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="white">
    <link rel="stylesheet" href="../dist/main.css">

</head>
<body  style="background: #F1F1F1 !important;">
  <div id="zhList">

  </div>
  <div id="bindingNew">
      <img src="../img/heardAddAcount(88_88).png" alt="">
      <span>绑定新账号</span>
  </div>





<view></view>

</body>
</html>
<script src="../dist/main.js"></script>
<script src="../dist/layui.js"></script>

<script>

    //账号列表
    (function () {
        getList()
        $("title").html(mt5Obj.title)
    })();
    function  getList() {
        $.ajax({
            url: mt5Obj.allUrl + "mt/user/get/mts",
            success: function (data) {
                var str="";
                var icon="";
                var type="";
                for(x in data.data){

                    if(data.data[x].status =="1"){
                        if (data.data[x].icon){
                            icon='<div class="tx" style="background:url('+data.data[x].icon+');background-size: cover"><img src="../img/check_right.png" alt=""></div>'
                        }else {
                            icon='<div class="tx" style="background:url(../img/signalHead(120_120).png);background-size: cover"><img src="../img/check_right.png" alt=""></div>'
                        }
                    }else{
                        if (data.data[x].icon){
                            icon='<div class="tx" style="background:url('+data.data[x].icon+');background-size: cover"></div>'
                        }else {
                            icon='<div class="tx" style="background:url(../img/signalHead(120_120).png);background-size: cover"></div>'
                        }
                    }



                    if(data.data[x].type=="0"){
                        type=' <div class="mowMt">信号源账号</div>'
                    }else{
                        type='<div class="followMt">跟随者账号</div>'
                    }

                    str=' <ul  class="mui-table-view qieZh" mtLogin="'+data.data[x].mtLogin+'" status="'+data.data[x].status+'" state="'+data.data[x].state+'" >'+
                        '          <li class="mui-table-view-cell">'+
                        '              <div class="mui-slider-right mui-disabled" >'+
                        '                  <a class="mui-btn mui-btn-red" href="javaScript:;" login="'+data.data[x].mtLogin+'">账号解绑</a>'+
                        '              </div>'+
                        '              <div class="mui-slider-handle clearFix">'+
                        icon +
                        '                  <div class="right">'+
                        '                      <div class="textBox">'+
                        '                          <span>'+data.data[x].realName+'</span>'+
                        '                          <span>'+data.data[x].mtLogin+'</span>'+
                        '                      </div>'+
                        type+
                        '                  </div>'+
                        '              </div>'+
                        '          </li>'+
                        '      </ul>';

                    $("#zhList").append(str)

                }


            }
        })
    }
    //切换

    mui("body").on('tap','.qieZh',function(){
         var mtLogin=$(this).attr("mtLogin");
         var status=$(this).attr("status");
         var state=$(this).attr("state");
         console.log(state)
         if(status=="1"){
             mui.alert("此账号已在线")
         }else if(state=="1"){
             mui.alert("该用户正在审核")
         }
         else{
             $.ajax({
                 url:mt5Obj.allUrl+"mt/user/update/online",
                 type:"put",
                 data:{
                     mtLogin:mtLogin
                 },success:function (data) {
                     if (data.data){
                         goUrl("mowList","1")
                     }else{
                         mui.alert("切换失败！")
                     }
                 }
             })
         }



    })
//    绑定新账号
    mui("body").on('tap','#bindingNew',function(){
       goUrl("level")


    })
//    解绑
    mui("body").on('tap','.mui-btn-red',function(){
        console.log(1)
        var login=$(this).attr("login");
        $.ajax({
            url:mt5Obj.allUrl+"mt/user/removeBinding",
            type:"put",
            data:{
                login:login
            },success:function (data) {
                if (data.data==0){
                    mui.alert("解除绑定成功",function(e) {
                        if(e.index == 0) {
                            $("#zhList .qieZh").remove();
                            getList();
                        }
                    });
                }else if(data.data==2){
                    mui.alert("解除绑定失败,您有没平仓的单号");
                }
                else if(data.data==1){
                    mui.alert("解除绑定失败,账号正在审核中");
                }
                else{
                    mui.alert("解除绑定失败！")
                }
            }
        })

    })


</script>




